// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.


suite("test_cast_to_float_from_datetimev2_0_part1") {

    // This test case is generated from the correspoinding be UT test case,
    // update this case if the correspoinding be UT test case is updated,
    // e.g.: ../run-be-ut.sh --run --filter=FunctionCastToDecimalTest.* --gen_regression_case
    sql "drop table if exists test_cast_to_float_from_datetimev2_0_part1_1_nullable;"
    sql "create table test_cast_to_float_from_datetimev2_0_part1_1_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_float_from_datetimev2_0_part1_1_nullable values (0, "0000-12-01 01:00:59"),(1, "0000-12-01 01:00:59"),(2, "0000-12-01 01:00:59"),(3, "0000-12-01 01:01:00"),(4, "0000-12-01 01:01:00"),(5, "0000-12-01 01:01:00"),(6, "0000-12-01 01:01:01"),(7, "0000-12-01 01:01:01"),(8, "0000-12-01 01:01:01"),(9, "0000-12-01 01:01:59"),(10, "0000-12-01 01:01:59"),(11, "0000-12-01 01:01:59"),(12, "0000-12-01 01:59:00"),(13, "0000-12-01 01:59:00"),(14, "0000-12-01 01:59:00"),(15, "0000-12-01 01:59:01"),(16, "0000-12-01 01:59:01"),(17, "0000-12-01 01:59:01"),(18, "0000-12-01 01:59:59"),(19, "0000-12-01 01:59:59"),
      (20, "0000-12-01 01:59:59"),(21, "0000-12-01 23:00:00"),(22, "0000-12-01 23:00:00"),(23, "0000-12-01 23:00:00"),(24, "0000-12-01 23:00:01"),(25, "0000-12-01 23:00:01"),(26, "0000-12-01 23:00:01"),(27, "0000-12-01 23:00:59"),(28, "0000-12-01 23:00:59"),(29, "0000-12-01 23:00:59"),(30, "0000-12-01 23:01:00"),(31, "0000-12-01 23:01:00"),(32, "0000-12-01 23:01:00"),(33, "0000-12-01 23:01:01"),(34, "0000-12-01 23:01:01"),(35, "0000-12-01 23:01:01"),(36, "0000-12-01 23:01:59"),(37, "0000-12-01 23:01:59"),(38, "0000-12-01 23:01:59"),(39, "0000-12-01 23:59:00"),
      (40, "0000-12-01 23:59:00"),(41, "0000-12-01 23:59:00"),(42, "0000-12-01 23:59:01"),(43, "0000-12-01 23:59:01"),(44, "0000-12-01 23:59:01"),(45, "0000-12-01 23:59:59"),(46, "0000-12-01 23:59:59"),(47, "0000-12-01 23:59:59"),(48, "0000-12-28 00:00:00"),(49, "0000-12-28 00:00:00"),(50, "0000-12-28 00:00:00"),(51, "0000-12-28 00:00:01"),(52, "0000-12-28 00:00:01"),(53, "0000-12-28 00:00:01"),(54, "0000-12-28 00:00:59"),(55, "0000-12-28 00:00:59"),(56, "0000-12-28 00:00:59"),(57, "0000-12-28 00:01:00"),(58, "0000-12-28 00:01:00"),(59, "0000-12-28 00:01:00"),
      (60, "0000-12-28 00:01:01"),(61, "0000-12-28 00:01:01"),(62, "0000-12-28 00:01:01"),(63, "0000-12-28 00:01:59"),(64, "0000-12-28 00:01:59"),(65, "0000-12-28 00:01:59"),(66, "0000-12-28 00:59:00"),(67, "0000-12-28 00:59:00"),(68, "0000-12-28 00:59:00"),(69, "0000-12-28 00:59:01"),(70, "0000-12-28 00:59:01"),(71, "0000-12-28 00:59:01"),(72, "0000-12-28 00:59:59"),(73, "0000-12-28 00:59:59"),(74, "0000-12-28 00:59:59"),(75, "0000-12-28 01:00:00"),(76, "0000-12-28 01:00:00"),(77, "0000-12-28 01:00:00"),(78, "0000-12-28 01:00:01"),(79, "0000-12-28 01:00:01"),
      (80, "0000-12-28 01:00:01"),(81, "0000-12-28 01:00:59"),(82, "0000-12-28 01:00:59"),(83, "0000-12-28 01:00:59"),(84, "0000-12-28 01:01:00"),(85, "0000-12-28 01:01:00"),(86, "0000-12-28 01:01:00"),(87, "0000-12-28 01:01:01"),(88, "0000-12-28 01:01:01"),(89, "0000-12-28 01:01:01"),(90, "0000-12-28 01:01:59"),(91, "0000-12-28 01:01:59"),(92, "0000-12-28 01:01:59"),(93, "0000-12-28 01:59:00"),(94, "0000-12-28 01:59:00"),(95, "0000-12-28 01:59:00"),(96, "0000-12-28 01:59:01"),(97, "0000-12-28 01:59:01"),(98, "0000-12-28 01:59:01"),(99, "0000-12-28 01:59:59"),
      (100, "0000-12-28 01:59:59"),(101, "0000-12-28 01:59:59"),(102, "0000-12-28 23:00:00"),(103, "0000-12-28 23:00:00"),(104, "0000-12-28 23:00:00"),(105, "0000-12-28 23:00:01"),(106, "0000-12-28 23:00:01"),(107, "0000-12-28 23:00:01"),(108, "0000-12-28 23:00:59"),(109, "0000-12-28 23:00:59"),(110, "0000-12-28 23:00:59"),(111, "0000-12-28 23:01:00"),(112, "0000-12-28 23:01:00"),(113, "0000-12-28 23:01:00"),(114, "0000-12-28 23:01:01"),(115, "0000-12-28 23:01:01"),(116, "0000-12-28 23:01:01"),(117, "0000-12-28 23:01:59"),(118, "0000-12-28 23:01:59"),(119, "0000-12-28 23:01:59"),
      (120, "0000-12-28 23:59:00"),(121, "0000-12-28 23:59:00"),(122, "0000-12-28 23:59:00"),(123, "0000-12-28 23:59:01"),(124, "0000-12-28 23:59:01"),(125, "0000-12-28 23:59:01"),(126, "0000-12-28 23:59:59"),(127, "0000-12-28 23:59:59"),(128, "0000-12-28 23:59:59"),(129, "0001-01-01 00:00:00"),(130, "0001-01-01 00:00:00"),(131, "0001-01-01 00:00:00"),(132, "0001-01-01 00:00:01"),(133, "0001-01-01 00:00:01"),(134, "0001-01-01 00:00:01"),(135, "0001-01-01 00:00:59"),(136, "0001-01-01 00:00:59"),(137, "0001-01-01 00:00:59"),(138, "0001-01-01 00:01:00"),(139, "0001-01-01 00:01:00"),
      (140, "0001-01-01 00:01:00"),(141, "0001-01-01 00:01:01"),(142, "0001-01-01 00:01:01"),(143, "0001-01-01 00:01:01"),(144, "0001-01-01 00:01:59"),(145, "0001-01-01 00:01:59"),(146, "0001-01-01 00:01:59"),(147, "0001-01-01 00:59:00"),(148, "0001-01-01 00:59:00"),(149, "0001-01-01 00:59:00"),(150, "0001-01-01 00:59:01"),(151, "0001-01-01 00:59:01"),(152, "0001-01-01 00:59:01"),(153, "0001-01-01 00:59:59"),(154, "0001-01-01 00:59:59"),(155, "0001-01-01 00:59:59"),(156, "0001-01-01 01:00:00"),(157, "0001-01-01 01:00:00"),(158, "0001-01-01 01:00:00"),(159, "0001-01-01 01:00:01"),
      (160, "0001-01-01 01:00:01"),(161, "0001-01-01 01:00:01"),(162, "0001-01-01 01:00:59"),(163, "0001-01-01 01:00:59"),(164, "0001-01-01 01:00:59"),(165, "0001-01-01 01:01:00"),(166, "0001-01-01 01:01:00"),(167, "0001-01-01 01:01:00"),(168, "0001-01-01 01:01:01"),(169, "0001-01-01 01:01:01"),(170, "0001-01-01 01:01:01"),(171, "0001-01-01 01:01:59"),(172, "0001-01-01 01:01:59"),(173, "0001-01-01 01:01:59"),(174, "0001-01-01 01:59:00"),(175, "0001-01-01 01:59:00"),(176, "0001-01-01 01:59:00"),(177, "0001-01-01 01:59:01"),(178, "0001-01-01 01:59:01"),(179, "0001-01-01 01:59:01"),
      (180, "0001-01-01 01:59:59"),(181, "0001-01-01 01:59:59"),(182, "0001-01-01 01:59:59"),(183, "0001-01-01 23:00:00"),(184, "0001-01-01 23:00:00"),(185, "0001-01-01 23:00:00"),(186, "0001-01-01 23:00:01"),(187, "0001-01-01 23:00:01"),(188, "0001-01-01 23:00:01"),(189, "0001-01-01 23:00:59"),(190, "0001-01-01 23:00:59"),(191, "0001-01-01 23:00:59"),(192, "0001-01-01 23:01:00"),(193, "0001-01-01 23:01:00"),(194, "0001-01-01 23:01:00")
      ,(195, null);
    """

    sql "set enable_strict_cast=true;"

    test {
        sql """select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part1_1_nullable order by 1;"""
        exception ""
    }
    sql "set enable_strict_cast=false;"
    qt_sql_1_non_strict 'select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part1_1_nullable order by 1;'

    sql "drop table if exists test_cast_to_float_from_datetimev2_0_part1_1_not_nullable;"
    sql "create table test_cast_to_float_from_datetimev2_0_part1_1_not_nullable(f1 int, f2 datetimev2(0)) properties('replication_num'='1');"
    sql """insert into test_cast_to_float_from_datetimev2_0_part1_1_not_nullable values (0, "0000-12-01 01:00:59"),(1, "0000-12-01 01:00:59"),(2, "0000-12-01 01:00:59"),(3, "0000-12-01 01:01:00"),(4, "0000-12-01 01:01:00"),(5, "0000-12-01 01:01:00"),(6, "0000-12-01 01:01:01"),(7, "0000-12-01 01:01:01"),(8, "0000-12-01 01:01:01"),(9, "0000-12-01 01:01:59"),(10, "0000-12-01 01:01:59"),(11, "0000-12-01 01:01:59"),(12, "0000-12-01 01:59:00"),(13, "0000-12-01 01:59:00"),(14, "0000-12-01 01:59:00"),(15, "0000-12-01 01:59:01"),(16, "0000-12-01 01:59:01"),(17, "0000-12-01 01:59:01"),(18, "0000-12-01 01:59:59"),(19, "0000-12-01 01:59:59"),
      (20, "0000-12-01 01:59:59"),(21, "0000-12-01 23:00:00"),(22, "0000-12-01 23:00:00"),(23, "0000-12-01 23:00:00"),(24, "0000-12-01 23:00:01"),(25, "0000-12-01 23:00:01"),(26, "0000-12-01 23:00:01"),(27, "0000-12-01 23:00:59"),(28, "0000-12-01 23:00:59"),(29, "0000-12-01 23:00:59"),(30, "0000-12-01 23:01:00"),(31, "0000-12-01 23:01:00"),(32, "0000-12-01 23:01:00"),(33, "0000-12-01 23:01:01"),(34, "0000-12-01 23:01:01"),(35, "0000-12-01 23:01:01"),(36, "0000-12-01 23:01:59"),(37, "0000-12-01 23:01:59"),(38, "0000-12-01 23:01:59"),(39, "0000-12-01 23:59:00"),
      (40, "0000-12-01 23:59:00"),(41, "0000-12-01 23:59:00"),(42, "0000-12-01 23:59:01"),(43, "0000-12-01 23:59:01"),(44, "0000-12-01 23:59:01"),(45, "0000-12-01 23:59:59"),(46, "0000-12-01 23:59:59"),(47, "0000-12-01 23:59:59"),(48, "0000-12-28 00:00:00"),(49, "0000-12-28 00:00:00"),(50, "0000-12-28 00:00:00"),(51, "0000-12-28 00:00:01"),(52, "0000-12-28 00:00:01"),(53, "0000-12-28 00:00:01"),(54, "0000-12-28 00:00:59"),(55, "0000-12-28 00:00:59"),(56, "0000-12-28 00:00:59"),(57, "0000-12-28 00:01:00"),(58, "0000-12-28 00:01:00"),(59, "0000-12-28 00:01:00"),
      (60, "0000-12-28 00:01:01"),(61, "0000-12-28 00:01:01"),(62, "0000-12-28 00:01:01"),(63, "0000-12-28 00:01:59"),(64, "0000-12-28 00:01:59"),(65, "0000-12-28 00:01:59"),(66, "0000-12-28 00:59:00"),(67, "0000-12-28 00:59:00"),(68, "0000-12-28 00:59:00"),(69, "0000-12-28 00:59:01"),(70, "0000-12-28 00:59:01"),(71, "0000-12-28 00:59:01"),(72, "0000-12-28 00:59:59"),(73, "0000-12-28 00:59:59"),(74, "0000-12-28 00:59:59"),(75, "0000-12-28 01:00:00"),(76, "0000-12-28 01:00:00"),(77, "0000-12-28 01:00:00"),(78, "0000-12-28 01:00:01"),(79, "0000-12-28 01:00:01"),
      (80, "0000-12-28 01:00:01"),(81, "0000-12-28 01:00:59"),(82, "0000-12-28 01:00:59"),(83, "0000-12-28 01:00:59"),(84, "0000-12-28 01:01:00"),(85, "0000-12-28 01:01:00"),(86, "0000-12-28 01:01:00"),(87, "0000-12-28 01:01:01"),(88, "0000-12-28 01:01:01"),(89, "0000-12-28 01:01:01"),(90, "0000-12-28 01:01:59"),(91, "0000-12-28 01:01:59"),(92, "0000-12-28 01:01:59"),(93, "0000-12-28 01:59:00"),(94, "0000-12-28 01:59:00"),(95, "0000-12-28 01:59:00"),(96, "0000-12-28 01:59:01"),(97, "0000-12-28 01:59:01"),(98, "0000-12-28 01:59:01"),(99, "0000-12-28 01:59:59"),
      (100, "0000-12-28 01:59:59"),(101, "0000-12-28 01:59:59"),(102, "0000-12-28 23:00:00"),(103, "0000-12-28 23:00:00"),(104, "0000-12-28 23:00:00"),(105, "0000-12-28 23:00:01"),(106, "0000-12-28 23:00:01"),(107, "0000-12-28 23:00:01"),(108, "0000-12-28 23:00:59"),(109, "0000-12-28 23:00:59"),(110, "0000-12-28 23:00:59"),(111, "0000-12-28 23:01:00"),(112, "0000-12-28 23:01:00"),(113, "0000-12-28 23:01:00"),(114, "0000-12-28 23:01:01"),(115, "0000-12-28 23:01:01"),(116, "0000-12-28 23:01:01"),(117, "0000-12-28 23:01:59"),(118, "0000-12-28 23:01:59"),(119, "0000-12-28 23:01:59"),
      (120, "0000-12-28 23:59:00"),(121, "0000-12-28 23:59:00"),(122, "0000-12-28 23:59:00"),(123, "0000-12-28 23:59:01"),(124, "0000-12-28 23:59:01"),(125, "0000-12-28 23:59:01"),(126, "0000-12-28 23:59:59"),(127, "0000-12-28 23:59:59"),(128, "0000-12-28 23:59:59"),(129, "0001-01-01 00:00:00"),(130, "0001-01-01 00:00:00"),(131, "0001-01-01 00:00:00"),(132, "0001-01-01 00:00:01"),(133, "0001-01-01 00:00:01"),(134, "0001-01-01 00:00:01"),(135, "0001-01-01 00:00:59"),(136, "0001-01-01 00:00:59"),(137, "0001-01-01 00:00:59"),(138, "0001-01-01 00:01:00"),(139, "0001-01-01 00:01:00"),
      (140, "0001-01-01 00:01:00"),(141, "0001-01-01 00:01:01"),(142, "0001-01-01 00:01:01"),(143, "0001-01-01 00:01:01"),(144, "0001-01-01 00:01:59"),(145, "0001-01-01 00:01:59"),(146, "0001-01-01 00:01:59"),(147, "0001-01-01 00:59:00"),(148, "0001-01-01 00:59:00"),(149, "0001-01-01 00:59:00"),(150, "0001-01-01 00:59:01"),(151, "0001-01-01 00:59:01"),(152, "0001-01-01 00:59:01"),(153, "0001-01-01 00:59:59"),(154, "0001-01-01 00:59:59"),(155, "0001-01-01 00:59:59"),(156, "0001-01-01 01:00:00"),(157, "0001-01-01 01:00:00"),(158, "0001-01-01 01:00:00"),(159, "0001-01-01 01:00:01"),
      (160, "0001-01-01 01:00:01"),(161, "0001-01-01 01:00:01"),(162, "0001-01-01 01:00:59"),(163, "0001-01-01 01:00:59"),(164, "0001-01-01 01:00:59"),(165, "0001-01-01 01:01:00"),(166, "0001-01-01 01:01:00"),(167, "0001-01-01 01:01:00"),(168, "0001-01-01 01:01:01"),(169, "0001-01-01 01:01:01"),(170, "0001-01-01 01:01:01"),(171, "0001-01-01 01:01:59"),(172, "0001-01-01 01:01:59"),(173, "0001-01-01 01:01:59"),(174, "0001-01-01 01:59:00"),(175, "0001-01-01 01:59:00"),(176, "0001-01-01 01:59:00"),(177, "0001-01-01 01:59:01"),(178, "0001-01-01 01:59:01"),(179, "0001-01-01 01:59:01"),
      (180, "0001-01-01 01:59:59"),(181, "0001-01-01 01:59:59"),(182, "0001-01-01 01:59:59"),(183, "0001-01-01 23:00:00"),(184, "0001-01-01 23:00:00"),(185, "0001-01-01 23:00:00"),(186, "0001-01-01 23:00:01"),(187, "0001-01-01 23:00:01"),(188, "0001-01-01 23:00:01"),(189, "0001-01-01 23:00:59"),(190, "0001-01-01 23:00:59"),(191, "0001-01-01 23:00:59"),(192, "0001-01-01 23:01:00"),(193, "0001-01-01 23:01:00"),(194, "0001-01-01 23:01:00");
    """

    sql "set enable_strict_cast=true;"

    test {
        sql """select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part1_1_not_nullable order by 1;"""
        exception ""
    }
    sql "set enable_strict_cast=false;"
    qt_sql_1_non_strict 'select f1, cast(f2 as float) from test_cast_to_float_from_datetimev2_0_part1_1_not_nullable order by 1;'

}